#include <bits/stdc++.h>
using namespace std;
const int N=5050;
int t,n;
int f[N];
int main(void){
    scanf("%d",&t);
    while(t--){
        scanf("%d",&n);
        int k=n-1;
        for(int i=2;i<=n;i++){
            f[i]=(f[i-1]+k)%i;
            k--;
        }
        printf("%d\n",f[n]+1);
    }
    return 0;
}